﻿@model HXDNB.DAL.UserInfo
<div class="widget-content">
    <div class="widget-box">
        <div class="widget-title">
            <span class="icon"><i class="icon-align-justify"></i></span>
            <h5>
                填写用户信息</h5>
        </div>
        <div class="widget-content nopadding">
            @if (IsPost == true)
            { 
                <div class="widget-content" style="border: 0px">
                    @if (ViewBag.Result > 0)
                    {
                        <div class="alert alert-success">
                            <a class="close" data-dismiss="alert" href="#">×</a>
                            <h4 class="alert-heading">
                                保存成功!</h4>
                            @if (ViewBag.Result == 1)
                            {                                
                                @Html.Raw("新用户已经成功添加，默认密码为“123456”！系统将会在用户第一次登陆时提醒及时修改密码。")
                            }
                            else
                            {
                                @Html.Raw("用户角色已修改成功，您可以点击“返回”按钮返回用户列表")
                            }
                        </div>
                    }
                    else
                    {
                        <div class="alert alert-error">
                            <a class="close" data-dismiss="alert" href="#">×</a>
                            <h4 class="alert-heading">
                                保存失败!</h4>
                            @if (ViewBag.Result == -1)
                            {
                                @Html.Raw("您输入的用户“" + Model.Name + "”已经存在，请尝试其他用户名。")
                            }
                            else
                            {
                                @Html.Raw("如确认您的数据填写无误，请联系管理员或查看错误日志。")
                            }
                        </div>
                    }
                </div>
            }
            <form action="@Url.Action("Info", "User", new { id = Request.QueryString["id"] })" method="post" class="form-horizontal">
            <div class="control-group">
                <label class="control-label">
                    用户名:</label>
                <div class="controls">
                    @Html.TextBoxFor(i => i.Name, new { @class = "span6", q = "q", maxL = 50 })
                    <span class="help-block">请输入登录时的用户名</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">
                    用户类型:</label>
                <div class="controls">
                    <div class="span6">
                        @{
                            List<SelectListItem> list = new UserBLL().GetListRoles();
                        }
                        @Html.DropDownListFor(i => i.Role, list)
                        <span class="help-block">请选择用户角色类型</span>
                    </div>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">
                    栏目权限:</label>
                <div class="controls">
                    <div class="span6">
                        @{
                            List<Meun> Meunlist = new MeunBLL().GetParents();
                            foreach (Meun item in Meunlist)
                            {
                            <label style="display:inline-block;">
                                <input type="checkbox" name="MeunRole" value="@item.ID"
                                                @Html.Raw((Model.MeunRole ?? "").Contains("," + item.ID + ",") ? "checked='checked'" : "") />
                                @item.Name
                            </label>
                            }
                        }
                        <span class="help-block">请选择用户的栏目权限</span>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <button type="submit" class="btn btn-success" onclick="return checkfrom2()">
                    保 存</button>
                <a href="@Url.Action("UserList", "User")" class="btn btn-danger">返 回</a>
            </div>
            </form>
        </div>
    </div>
</div>
